import time
from Unit_01.Page.page1 import Page1
from Unit_01.Base.Base import Base
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

class Page2(Page1,Base):

    # 定位器
    # 1 点击我的酒仙 href="https://member.jiuxian.com/index.htm"
    jiuxian_loc=(By.XPATH,'//a[@href="https://member.jiuxian.com/index.htm"]')
    # 2 点击取消 class="uGuideClose"
    close_loc=(By.CLASS_NAME,'uGuideClose')
    # 4 点击收货地址 /html/body/div[4]/div[1]/div[2]/div[4]/a[3]/span
    address_loc=(By.XPATH,'/html/body/div[4]/div[1]/div[2]/div[4]/a[3]/span')
    # 5 点击添加新地址 class="addressTrue"
    address_new_loc=(By.CLASS_NAME,'addressTrue')
    # 6 输入收货人 id="people"
    poeple_loc=(By.ID,'people')
    # 选择地区 省 id="province" value="2"
    province_loc=(By.ID,'province')
    # 选择地区 市 id="city" index="1"
    city_loc= (By.ID, 'city')
    # 选择地区 县 id="district" 昌平区
    district_loc=(By.ID,'district')

    # 输入详细地址 id="address" name="addressMore"
    addressMore_loc=(By.NAME,'addressMore')
    # 输入手机号 id="iphone" name="mobile"
    mobile_loc=(By.NAME,'mobile')
    # 点击提交 class="qjwSubmit2"
    qjwSubmit2=(By.CLASS_NAME,'qjwSubmit2')

    # 点击确定
    binggo_loc=(By.XPATH,'/html/body/div[8]/div/div[3]/span[1]/b')


    # 页面元素的封装（操作）
    # 点击我的酒仙
    def jiuxian(self):
        self.click(self.jiuxian_loc)

    # 点击取消
    def close(self):
        self.click(self.close_loc)

    # 点击收货地址
    def address(self):
        self.click(self.address_loc)

    # 点击添加新地址
    def address_new(self):
        self.click(self.address_new_loc)

    # 输入收货人
    def people(self):
        self.send_keys(self.poeple_loc,'qisan')

    # 选择地区 省
    def province(self):
        self.select_value(self.province_loc,'2')

    # 选择地区 市
    def city(self):
        self.select_index(self.city_loc, 1)

    # 选择地区 县
    def district(self):
        self.select_text(self.district_loc, '昌平区')

    # 输入详细地址
    def addressMore(self):
        self.send_keys(self.addressMore_loc,'北京八维')

    # 输入手机号
    def mobile(self):
        self.send_keys(self.mobile_loc,'15253006116')

    # 提交
    def submit(self):
        self.click(self.qjwSubmit2)

    # 点击确定
    def bingo(self):
        self.click(self.binggo_loc)

    # 业务逻辑
    def jiuxian_luoji2(self):
        self.jiuxian_luoji1()
        self.jiuxian()
        # 多窗口切换
        self.new_window()

        self.close()
        # 向下滑动800
        self.scroll_x(800)
        self.address()
        self.address_new()
        self.people()
        self.province()
        self.city()
        self.district()
        self.addressMore()
        self.mobile()
        self.submit()
        self.bingo()